<div [formGroup]="form" class="age-input">
  <div>
    <mat-form-field class="example-full-width date-field-width" color="primary">
      <input matInput placeholder="出生日期" formControlName="birthday" [matDatepicker]="birthDatepicker">
      <mat-datepicker-toggle matSuffix [for]="birthDatepicker"></mat-datepicker-toggle>
      <mat-datepicker #birthDatepicker></mat-datepicker>
      <mat-error>日期不正确</mat-error>
    </mat-form-field>
  </div>
  <ng-container formGroupName="age">
    <div class="age-num">
      <mat-form-field class="age-field-width">
        <input matInput formControlName="ageNum" placeholder="年龄">
      </mat-form-field>
    </div>
    <div>
      <mat-button-toggle-group name="fontStyle" aria-label="Font Style" formControlName="ageUnit">
        <mat-button-toggle *ngFor="let unit of ageUnits" [value]="unit.value">{{unit.label}}</mat-button-toggle>
      </mat-button-toggle-group>
    </div>
  </ng-container>
</div>
<mat-error *ngIf="form.get('age').hasError('ageInvalid')">年龄或单位不正确</mat-error>
